<script setup>
import axios from 'axios'
import { onMounted, ref } from 'vue'
import { useStore } from 'vuex'
const store = useStore()
const pagination = ref([])
const currentPage = ref(1)
const pageSize = ref(10)
const score = ref([])

const studentid = store.state.userStore.userInfo.data.data.studentId
const loading = ref(null)

onMounted(() => {
  loading.value = true
  handleCurrentChange()
})

const handleCurrentChange = () => {
  axios.get('api/scorecontroller/score1/' + currentPage.value + '/' + pageSize.value + '/' + studentid).then(res => {
    loading.value = false
    // score.value = res.data.records
    console.log(score)
    pagination.value = res.data
    console.log(pagination.value)
  })
}
</script>

<template>
<div class="table">
    <p class="title">我的分数</p>
    <div class="box"></div>
    <section class="content-el">
      <el-table ref="filterTable" :data="pagination" v-loading="loading">
        <el-table-column
          prop="answerDate"
          label="考试日期"
          sortable
          width="300"
          column-key="answerDate"
          :filters="filter"
          :filter-method="filterHandler">
        </el-table-column>
        <el-table-column
          prop="subject"
          label="课程名称"
          width="300"
          filter-placement="bottom-end">
          <template v-slot="scope">
            <el-tag>{{scope.row.subject}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="etScore" label="考试分数" width="200"></el-table-column>
        <el-table-column label="是否及格" width="100">
          <template v-slot="scope">
            <el-tag :type="scope.row.etScore >= 60 ? 'success' : 'danger'">{{scope.row.etScore >= 60 ? "及格" : "不及格"}}</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <el-row type="flex" justify="center" align="middle" class="pagination">
         <el-pagination
      v-model:currentPage="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[1,2,3]"
      :small="small"
      :disabled="disabled"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="30"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
      </el-row>
    </section>
  </div>
</template>

<style scoped>
.pagination {
  padding-top: 20px;
}
.table .title {
  width: 980px;
  margin: 0 auto;
    margin: 20px;
}
  .content-el {
    background-color: #fff;
    padding: 20px;
  }
</style>
